<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="header.jsp"%>
		<div class="flex-container">
			<%@ include file="leftmenu.jsp"%>
			<div class="right-container right_container_content">
			    <div class="right_content right_content_main">
			    	<div class="header header_line">
			    		<h6>添加账号</h6>
			    	</div>
			    	<div class="addAccount">
			    	    <div class="form_block">
			    	    	<form id="usrform">
			    	    		<div class="from_group">
			    	    			<label>账号</label>
			    	    			<input id="userName" name="userName" required class="form_control" type="text"/>
			    	    		</div>
			    	    		<div class="from_group">
			    	    			<label>角色</label>
			    	    			<select id="roleid" name="roleid" required class="form_control" value="请选择">
			    	    			<option>请选择</option>
			    	    			<option value="1">载体</option>
			    	    			<option value="2">新城</option>
			    	    			</select>
			    	    			<input type="hidden" id="rolename" name="rolename"/>
			    	    		</div>
			    	    		<div class="from_group">
			    	    			<label>载体</label>
			    	    			<select id="carrier" name="carrier" required class="form_control" value="请选择" style="background-color: #EEEEEE;" disabled="disabled">
			    	    			<option>请选择</option>
			    	    			</select>
			    	    		</div>
			    	    		<div class="from_group">
			    	    			<label>新城</label>
			    	    			<select id="newcity" name="newcity" required class="form_control" value="请选择" style="background-color: #EEEEEE;" disabled="disabled">
			    	    			<option>请选择</option>
			    	    			</select>
			    	    		</div>
			    	    		<div class="from_group">
			    	    			<label>密码</label>
			    	    			<input id="userPassWord" name="userPassword" required class="form_control" type="password"/>
			    	    		</div>
			    	    		<div class="from_group">
			    	    			<label>确认密码</label>
			    	    			<input id="confirmpass" class="form_control" required type="password"/>
			    	    		</div>
			    	    		<div class="from_group">
			    	    			<label></label>
			    	    			<a class="form_btn">提交</a>
			    	    		</div>
			    	    	</form>
			    	    </div>
			        </div>
			    </div>
			   
			</div>
		</div>
	</body>
	<script>
	var newcitys=[{name:"泾河新城",value:"1"},
	              {name:"空港新城",value:"2"},
	              {name:"秦汉新城",value:"3"},
	              {name:"沣东新城",value:"4"},
	              {name:"沣西新城 ",value:"5"}];
	var carry=
	[{name:"寿平民宿小镇", value:"1"},
	 {name:"数字文化+语言服务主题众创空间", value:"10"},
	 {name:"生物技术及研发主题众创空间", value:"11"},
	 {name:"自由贸易主题众创空间", value:"12"},
	 {name:"西安科统众创空间", value:"13"},
	 {name:"协同创新港孵化加速器", value:"14"},
	 {name:"腾讯众创空间", value:"15"},
	 {name:"京东云电商创新中心", value:"16"},
	 {name:"沣东都市农业众创空间", value:"17"},
	 {name:"天海星双创服务中心一期", value:"18"},
	 {name:"沣东新城沣滨优美小镇生态旅游园区（诗经里）", value:"19"},
	 {name:"西咸新区泾河新城茯茶镇", value:"2"},
	 {name:"沣东自贸产业园一期", value:"20"},
	 {name:"西部云谷创新创业发展中心孵化器", value:"21"},
	 {name:"信息产业园人力资源创新孵化基地", value:"22"},
	 {name:"西咸新区互联网创业孵化基地", value:"23"},
	 {name:"沣西新城大学生创业基地", value:"24"},
	 {name:"圣泓·云谷众创基地", value:"25"},
	 {name:"西咸新区光谷创业咖啡", value:"26"},
	 {name:"西部云谷·乐创空间", value:"27"},
	 {name:"西咸新区万众创业场", value:"28"},
	 {name:"中航（西咸）智慧城市双创大厦", value:"29"},
	 {name:"泾河新城产业孵化基地", value:"3"},
	 {name:"西安蒜泥科技孵化器", value:"30"},
	 {name:"中国西部科技创新港智慧学镇", value:"31"},
	 {name:"西咸新区沣西新城大数据创业孵化基地", value:"32"},
	 {name:"陕西国际商贸学院创新学院 ", value:"33"},
	 {name:"陕西服装工程学院众创空间", value:"34"},
	 {name:"陕西科技大学镐京学院众创基地", value:"35"},
	 {name:"陕西中医药大学众创空间", value:"36"},
	 {name:"咸阳职业技术学院众创空间", value:"37"},
	 {name:"陕西（西咸新区人力资源服务产业园）", value:"38"},
	 {name:"西咸文旅众创空间", value:"39"},
	 {name:"温商高端制造产业园", value:"4"},
	 {name:"美国科技产业园", value:"5"},
	 {name:"航投大厦", value:"6"},
	 {name:"空港国际商务中心", value:"7"},
	 {name:"自贸大都汇", value:"8"},
	 {name:"空港保税自贸大厦", value:"9"}

];
	$('#roleid').change(function(){

	　　　　　　$("#newcity").empty();
			$("#carrier").empty();
	　　　　　　var p1=$(this).children('option:selected').val();//这就是selected的值  　　　　　
			var options=$("#roleid option:selected");		
			$("#rolename").val(options.text());	
			if(p1=="1"){
				$("#carrier").removeAttr("style");
				$("#carrier").removeAttr("disabled");
				carry.forEach(function(i,index){
					$("#carrier").append("<option value="+i.value+">"+i.name+"</option>");
		　　　　　　})
		      $("#newcity").attr({style:"background-color: #EEEEEE;",disabled:"disabled"});
				
	　　　　　　}else if(p1=="2"){
				$("#newcity").removeAttr("style");
				$("#newcity").removeAttr("disabled");
				newcitys.forEach(function(i,index){
					$("#newcity").append("<option value="+i.value+">"+i.name+"</option>");
		　　　　　　})
		      $("#carrier").attr({style:"background-color: #EEEEEE;",disabled:"disabled"});
	　　　　　　}
	})  
	$(".form_btn").click(function(){
		if(toVaild()){
			 $.ajax({
				    type : "post",
				    url : "admin/addUser",
				    data:$("#usrform").serialize(),
				    dataType:"json",
				    success : function (data) {
				         alert(data);   //data即为后台返回的数据
				         window.location.href="admin/addAccount";
					}
			 })
		}
	})
	function toVaild(){
		var str1=$("#userPassWord").val();
		var str2=$("#confirmpass").val();
		var str3=$("#userName").val();
		var options=$("#roleid option:selected");
		if(str3.length == 0){alert("请输入账号！");return false;}
		if(options.val() == "请选择"){alert("请选择角色！");return false;}
		if(str1.length == 0){alert("请输入密码！");return false;}
		
		if(str1==str2){
			alert("校验成功，之后进行提交");
			return true;
		}else{
			alert("两次输入密码不同！");
			return false;
		}
	}
	</script>
</html>
